<%@ include file="/en/jsp/static.jsp" %>
<%@ page import="linuxbox.bbs.logic.*" %>
<%@ page import="linuxbox.bbs.bean.*" %>
<%@ page import="java.util.*" %>
<%@ taglib uri="/linuxbox/bbs.tld" prefix="bbs" %>


<%
  String sShowCount = request.getParameter("show");

  if (sShowCount == null || sShowCount.equals(""))
    sShowCount = "25";

  int showMax = Integer.parseInt(sShowCount);
  java.sql.Date today = new java.sql.Date(System.currentTimeMillis());
  java.sql.Time now = new java.sql.Time(System.currentTimeMillis());

  BbsManager bm = BbsManager.getInstance();
%>
<jsp:include page="/en/jsp/header.jsp" flush="true"/>

<script Language="JavaScript">

function onChangeCategory()
{
    document.theForm.submit();
}
</SCRIPT>


<table width="100%" height=26 align=middle border=0 cellpadding=0 cellspacing=0 bgcolor="#f4f4f4" style="font-size:16px;color:#d05000">
  <tr>
    <td>
      &nbsp;<img src="<%=BoxStatic.imageDir%>itemball.jpg" width=14 height=15 border=0 align="absmiddle">
      <b><%=boxName%> - BBS</b>
    </td>
<FORM action="<%=BoxStatic.servletDir%>BbsContentAction" method="POST" name="theForm" >
    <td ALIGN="right" valign="top">
      <a href="<%=BoxStatic.jspDir%>bbs/BbsNewList.jsp">New List</a>&nbsp;|&nbsp;

      <a href="<%=BoxStatic.jspDir%>bbs/BbsQueryAll.jsp">Search</a>

      &nbsp;|&nbsp;View Category
        <SELECT NAME="CAT_ID" onchange="onChangeCategory()">
          <option selected>All Categories</option>
          <bbs:BbsCatList listType="list"/>
        </select>
    </td>
</FORM>
  </tr>
</table>

<hr width="100%" color=#E06000 align=left>


<table width="100%" border=0 cellpadding=0 cellspacing=0>
  <tr><td>
    <table width="100%">
      <tr>
        <td>
          Showing the newest <%=showMax%> messages
        </td>
        <td align=right>
          <a href="<%=BoxStatic.jspDir%>bbs/BbsNewList.jsp?show=25">Top25</a>&nbsp;|&nbsp;
          <a href="<%=BoxStatic.jspDir%>bbs/BbsNewList.jsp?show=50">Top50</a>&nbsp;|&nbsp;
          <a href="<%=BoxStatic.jspDir%>bbs/BbsNewList.jsp?show=100">Top100</a>&nbsp;|&nbsp;
          <a href="<%=BoxStatic.jspDir%>bbs/BbsNewList.jsp?show=200">Top200</a>
        </td>
      </tr>
    </table>
  </td></tr>
  <tr><td>
    <table width="100%" border=0 cellpadding=1 cellspacing=1 style="font:14px Arial"  bgColor=#dddddd>
      <tr bgcolor="#7EC1F3">
        <th>Category</th>
        <th align="left">Subject</th>
      </tr>
<%
  try {
    BbsMsgKey key = null;
    BbsMsg msg = null;

    ArrayList keys = bm.findNewList(showMax);

    int i = 0;
    for (Iterator it = keys.iterator(); it.hasNext(); ) {
      key = (BbsMsgKey)it.next();
      msg = bm.getBbsMsg(key);

        long lMsgID = msg.getID();
        long lTopicID = msg.getTopicID();
      String sAuthor = msg.getAuthor();
      java.sql.Date dtSubDate = msg.getSubDate();
      java.sql.Time tmSubTime = msg.getSubTime();
      String sSubject = msg.getSubject();
      int iCategory = msg.getCategory();
      String sCatName = msg.getCatName();

      String proptime = dtSubDate.toString() + " " + tmSubTime.toString();
      if (sSubject == null || sSubject.equals(""))
         sSubject = "(No Subject)";
%>
      <tr <% if ((i++ % 2) == 0) out.print("bgcolor=#f0f0f0"); %>>
      <td align="center" nowrap><%=sCatName%></td>
      <td nowrap>
          <a href="<%=BoxStatic.servletDir%>BbsViewAction?CAT_ID=<%=iCategory%>&MSG_ID=<%=lMsgID%>">
              <%=sSubject%> [ <%=sAuthor%> <%=proptime%> ]</a>
      </td>
      </tr>
<%
    }
  } catch(Exception e) {
    System.out.println("Error : " + e.getMessage());
  }
%>
    </table>
  </td></tr>
</table>

<hr width="100%" color=#E06000 align=left>

<jsp:include page="/en/jsp/footer.jsp" flush="true"/>
